package cn.edu.hnu.homework.api.Mapper;

import cn.edu.hnu.homework.api.Bean.Person;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface PersonMapper {

    @Select("select * from person")
    List<Person> getAll();

    @Select("select * from person where username = #{username}")
    List<Person> getByUsername(String username);

    @Update("update person set name = #{param2}, age = #{param3}, phone = #{param4} where username = #{param1}")
    void upateByUsername(String username, String name, int age, String phone);
    // TODO: mybait transaction
    @Insert("INSERT INTO `news_program`.`person`(`username`, `name`, `age`, `phone`) VALUES (#{param1}, #{param2}, #{param3}, #{param4});")
    void insert(String username, String name, int age, String phone);


}
